package o;

import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView.a;
import androidx.recyclerview.widget.RecyclerView.s;
import com.huawei.appgallery.foundation.card.base.bean.KeywordInfo;
import com.huawei.appgallery.search.ui.cardbean.SearchRecommendCardBean;
import huawei.widget.HwButton;
import java.util.List;
import o.cuv.b;
import o.cuv.e;

public class cvl extends a implements OnClickListener {
    protected cih ˊ;
    private List<KeywordInfo> ˋ;
    protected chy ˎ;

    class d extends s {
        final /* synthetic */ cvl ʻॱ;
        private HwButton ॱᐝ;

        private d(cvl o_cvl, View view) {
            this.ʻॱ = o_cvl;
            super(view);
            this.ॱᐝ = (HwButton) view.findViewById(b.ᶥ);
        }
    }

    public cvl(List<KeywordInfo> list) {
        this.ˋ = list;
    }

    public void ˊ(List<KeywordInfo> list) {
        this.ˋ = list;
        ˊ();
    }

    public void ॱ(chy o_chy, cih o_cih) {
        this.ˎ = o_chy;
        this.ˊ = o_cih;
    }

    @NonNull
    public s ˎ(@NonNull ViewGroup viewGroup, int i) {
        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(e.ˈ, viewGroup, false);
        if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
            inflate.setLayoutDirection(1);
        }
        return new d(inflate);
    }

    public void ॱ(@NonNull s sVar, int i) {
        if (sVar instanceof d) {
            ˏ(((d) sVar).ॱᐝ, i);
        }
    }

    public int ˏ() {
        if (CollectCheck.isEmpty(this.ˋ)) {
            return 0;
        }
        if (this.ˋ.size() <= 10) {
            return this.ˋ.size();
        }
        return 10;
    }

    public void onClick(View view) {
        if (view == null || this.ˎ == null || !(this.ˊ.ˌ() instanceof SearchRecommendCardBean)) {
            cux.ˏ.ˏ("RecommendCardAdapter", " Click item event wrong.");
            return;
        }
        SearchRecommendCardBean searchRecommendCardBean = (SearchRecommendCardBean) this.ˊ.ˌ();
        searchRecommendCardBean.ʼ(((Integer) view.getTag()).intValue());
        this.ˎ.ˏ(7, this.ˊ);
        dyk.ॱ(this.ˊ.ˉ().getContext(), searchRecommendCardBean.ॱˉ(), searchRecommendCardBean.ᶥ());
    }

    protected void ˏ(HwButton hwButton, int i) {
        if (hwButton == null || i < 0 || i >= ˏ() || this.ˋ.get(i) == null) {
            cux.ˏ.ˏ("RecommendCardAdapter", "itemView or position is invalid.");
            return;
        }
        hwButton.setText(((KeywordInfo) this.ˋ.get(i)).ॱ());
        hwButton.setTag(Integer.valueOf(i));
        hwButton.setOnClickListener(new ckt(this));
    }
}
